package computer.data;

import java.sql.*;
import javax.sql.DataSource;

import com.mchange.v2.c3p0.ComboPooledDataSource;

// public class ConnectionPool {
public class DataSourceUtils {
	private static DataSource ds=new ComboPooledDataSource();
	/*
	 * private ConnectionPool() { try { InitialContext ic = new InitialContext();
	 * dataSource = (DataSource) ic.lookup("java:/comp/env/jdbc/musicDB"); } catch
	 * (NamingException e) { System.err.println(e); } }
	 */

	/*
	 * public Connection getConnection() { try { return dataSource.getConnection();
	 * } catch (SQLException sqle) { System.err.println(sqle); return null; } }
	 */

	public static DataSource getDataSource() {
		return ds;
	}

	public static Connection getConnection() throws SQLException {
		return ds.getConnection();
	}

	public static void freeConnection(Connection c) {
		try {
			c.close();
		} catch (SQLException sqle) {
			System.err.println(sqle);
		}
	}
}